package com.yuelan.apartment.controller;

import com.yuelan.apartment.service.ApaRentService;
import com.yuelan.common.annotation.Log;
import com.yuelan.common.core.controller.BaseController;
import com.yuelan.common.core.domain.AjaxResult;
import com.yuelan.common.core.page.TableDataInfo;
import com.yuelan.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @description:
 * @Author: ZhaoYi
 * @date: 24-6-28 2:39
 */
@RestController
@RequestMapping("/rent")
public class ApaRentController extends BaseController {

    @Autowired
    private ApaRentService apaRentService;


    @GetMapping("/profit")
    @PreAuthorize("@ss.hasAnyRoles('admin,common')")
    public AjaxResult rentProfit(String year) {
        return success(apaRentService.yearProfit(year));
    }


    @GetMapping("/billStatus")
    @PreAuthorize("@ss.hasAnyRoles('admin,common')")
    public TableDataInfo viewRentBillType(String status, int pageNum, int pageSize) {
        return apaRentService.billStatus(status, pageNum, pageSize);
    }


    @GetMapping("/updateBill")
    @PreAuthorize("@ss.hasAnyRoles('admin,common')")
    @Log(title = "处理账单逾期", businessType = BusinessType.UPDATE)
    public AjaxResult rentBillOverdue() {
        apaRentService.updateBillOverdueCountDownLatch();
        return success();
    }


}
